Fix: Automatically close PRs when directory is deleted during refresh#13227
Draft
Fix: Automatically close PRs when directory is deleted during refresh#13227
Conversation
Co-authored-by: honeyankit <5500812+honeyankit@users.noreply.github.com>
Co-authored-by: honeyankit <5500812+honeyankit@users.noreply.github.com>
Co-authored-by: honeyankit <5500812+honeyankit@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix dependency file not found error on deleted directory
Fix: Automatically close PRs when directory is deleted during refresh
Oct 3, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a directory containing dependency manifests is deleted from a repository, Dependabot alerts are properly closed, but associated pull requests remain open. When users attempt to refresh or rebase these PRs using commands like
@dependabot rebase, the job fails with adependency_file_not_founderror because Dependabot tries to fetch files from the deleted directory.This issue affects customers who:
Related to #10684.
Solution
Modified
FileFetcherCommandto detect when a PR refresh operation fails due to missing directories or files, and automatically close the PR with reason:dependency_removed.Key Changes
Added
handle_missing_directory_for_pr_updatemethod:This method is called during error handling in
perform_job, ensuring that when file fetching fails during a PR refresh:Impact
Testing
Added comprehensive test coverage:
DependencyFileNotFound→ closes PR ✅DirectoryNotFound→ closes PR ✅All tests pass, and the code passes rubocop and Sorbet type checking.
Example Scenario
Before this fix:
users/evam/excel_jobs/poetry.lockusers/evam/excel_jobs/directory@dependabot rebaseon PR v0.171.4 #4678dependency_file_not_founderror ❌After this fix:
users/evam/excel_jobs/poetry.lockusers/evam/excel_jobs/directory@dependabot rebase💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.